﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutReport.cshtml";
}





        <script language="javascript">

            $(document).ready(function () {
                $("#selectFinancialInstrument").val('@ViewBag.financialInstrument');


                $("#selectAssetClass").val('@ViewBag.assetClass');
                $("#txtSymbol").val('@ViewBag.symbol');

                $("#selectKeepAt").val('@ViewBag.keepAt');
                $("#selectTimeToMaturityYearFrom").val('@ViewBag.timeToMaturityYearFrom');
                $("#selectTimeToMaturityMonthFrom").val('@ViewBag.timeToMaturityMonthFrom');
                $("#selectTimeToMaturityYearTo").val('@ViewBag.timeToMaturityYearTo');
                $("#selectTimeToMaturityMonthTo").val('@ViewBag.timeToMaturityMonthTo');
                $("#selectAfterMaturedYearFrom").val('@ViewBag.afterMaturedYearFrom');
                $("#selectAfterMaturedMonthFrom").val('@ViewBag.afterMaturedMonthFrom');
                $("#selectAfterMaturedYearTo").val('@ViewBag.selectAfterMaturedYearTo');
                $("#selectAfterMaturedMonthTo").val('@ViewBag.selectAfterMaturedMonthTo');
                $("#dtTranDateFrom").val('@ViewBag.tranDateFrom');
                $("#dtTranDateTo").val('@ViewBag.tranDateTo');
                $("#selectStatus").val('@ViewBag.atatus');

                 
                if ('@ViewBag.min' == 'on') {
                    $("#chkMin").attr('checked', true);
                } else if ('@ViewBag.max' == 'on') {
                    $("#chkMax").attr('checked', true);
                } else {
                    $("#chkAll").attr('checked', true);
                }

                
                

          //      $("#chkMin").val('@ViewBag.min');
                $("#selectRelated").val('@ViewBag.related');

                if (parseInt('@ViewBag.financialInstrument') > 0) {

                    $("#btnExport").removeAttr("disabled");
                } else {
                    $("#btnExport").attr("disabled", "disabled");
                }


                $.ajax({
                    url: '@Url.Action("GetCompany", "Master")',
                    type: 'POST',
                    dataType: 'json',
                    data: {},
                    success:
                                function (data) {
                                    var jsonobj = eval('(' + data + ')');
                                    var select = $("#SelectCompany");


                                    $.each(jsonobj, function (index, itemData) {

                                        select.append($('<option/>', {
                                            value: itemData.key,
                                            text: itemData.val
                                        }));
                                    });
                                    $("#SelectCompany").val('@ViewBag.company');
                            }
                });

                $.ajax({
                    url: '@Url.Action("GetIssuer", "Master")',
                    type: 'POST',
                    dataType: 'json',
                    data: {},
                    success:
                                function (data) {
                                    var jsonobj = eval('(' + data + ')');
                                    var select = $("#SelectIssuer");


                                    $.each(jsonobj, function (index, itemData) {

                                        select.append($('<option/>', {
                                            value: itemData.key,
                                            text: itemData.val
                                        }));
                                    });
                                    $("#SelectIssuer").val('@ViewBag.issuer');
                                                }
                });

                $("#btnExport").click(function () {
                    //alert('export');
                    if ($("#selectFinancialInstrument").val() != '0') {
                        $("#formReport").submit();
                    } else {
                        alert('กรุณาระบุ Financial Instrument');
                    }

                })

            });//end doc ready

                                        $(function () {
                                            $("#dtTranDateTo").datepicker({ dateFormat: 'dd/mm/yy' });
                                        });
                                        $(function () {
                                            $("#dtTranDateFrom").datepicker({ dateFormat: 'dd/mm/yy' });
                                        });
                                        /*
                                        $(function () {
                                            $("#formReport").submit(function (event) {
                                           
                                                var Instrument = $('#selectFinancialInstrument').val();
                                                if (Instrument!='0') {
                                                    //do something before submit the form
                                                    return true;
                                                } else {
                                                    alert('กรุณาระบุ Financial Instrument');
                                                    return false;
                                                }
                                            
                                            })
                                        });
                                        */

                                        function gogo(page, folder, id) {

                                            if (folder == 'FixedIncome') {
                                                var url = '../' + folder + '/' + page + '?fixedincomeID=' + id;
                                                //alert(url);
                                                document.location.href = url;
                                            } else if (folder == 'Equity') {
                                                document.location.href = '../' + folder + '/' + page + '?headerId=' + id;
                                            } else if (folder == 'UnitTrust') {
                                                document.location.href = '../' + folder + '/' + page + '?headerId=' + id;
                                            } else if (folder == 'Loan') {
                                                document.location.href = '../' + folder + '/' + page + '?headerId=' + id;
                                            } else if (folder == 'Deposit') {
                                                document.location.href = '../' + folder + '/' + page + '?headerId=' + id;
                                            }
                                        }
</script>

<style type="text/css">
.WGtable{
    border : 1px solid #809FFF;
    background-color: #E6FFFF;
    color:  #6078BF;
    border-collapse: collapse;
}

.WGheader{
    background-color: #6078BF;
    color: #000000;
}

.WGalternate{
    background-color: #EEE6FF;
}

  .Wbgrid { margin: 4px; border-collapse: collapse; width: 700px; }
  .Wbgrid th, .Wbgrid td { border: 1px solid #C0C0C0; padding: 5px; }
  .Wbhead { background-color: #E8E8E8; font-weight: bold; color: #000000; }
  .Wbalt { background-color: #E8E8E8; color: #000; }

  .px60{width: 60px;}
  .px90{width: 90px;}
  .px120{width: 120px;}
  .px200{width: 200px;}
  .px300{width: 300px;}
</style> 

    <h2>@ViewBag.Message</h2>
    <p>
        <table width="900" border="0" align="center">
        <tr>
          <td>
@using (Html.BeginForm("Search", "Home", FormMethod.Post ,new { id = "formReport" }))
{
		      <table  class="tableform" width="100%"  border="0" align="center" cellspacing="2">
                <tr>
                  <td width="200"><div align="right">Company: </div></td>
                  <td width="10">&nbsp;</td>
                  <td width="621">
                      <select  id="SelectCompany" name="SelectCompany" >
                    <option value="0">--Select data--</option>
                   
                    </select></td>
                </tr>
                <tr>
                  <td><div align="right">Financial Instrument  : </div></td>
                  <td>&nbsp;</td>
                  <td><select name="selectFinancialInstrument" id="selectFinancialInstrument">
                    <option value="0">--Select data--</option>
                    <option value="1">Fixed Income Securities</option>
                    <option value="2">Equity Securities</option>
                    <option value="3">Unit Trust</option>
                    <option value="4">Derivative Securities</option>
                    <option value="5">Loans</option>
                       <option value="6">deposit finance</option>
                  </select></td>
                </tr>
				  <tr>
                  <td><div align="right">Asset Class  : </div></td>
                  <td>&nbsp;</td>
                  <td><select name="selectAssetClass" id="selectAssetClass">
                    <option  value="0">--Select data--</option>
                    <option value="1">Bank</option>
                    <option value="2">Bond</option>
                    <option value="3">Loans</option>
                  </select></td>
                </tr>
				  <tr>
                  <td><div align="right">Symbol  : </div></td>
                  <td>&nbsp;</td>
                  <td><input name="txtSymbol" type="text" id="txtSymbol" ></td>
                </tr>
				  <tr>
                  <td><div align="right">Issuer   : </div></td>
                  <td>&nbsp;</td>
                  <td><select name="SelectIssuer" id="SelectIssuer">
                    <option  value="0">--Select data--</option>
                   
                  </select></td>
                </tr>
                <tr>
                  <td><div align="right">Keep at   : </div></td>
                  <td>&nbsp;</td>
                  <td><select name="selectKeepAt" id="selectKeepAt">
                    <option  value="0">--Select data--</option>
                    <option value="1">Custodian</option>
                    <option value="2">OIC</option>
                    <option value="3">Safe</option>
                  </select></td>
                </tr>
                <tr>
                  <td><div align="right">Time to Maturity  : </div></td>
                  <td>&nbsp;</td>
                  <td>from&nbsp;&nbsp; <select name="selectTimeToMaturityYearFrom" id="selectTimeToMaturityYearFrom" style="width: 50px" >
                    <option  value="0">--Year--</option>
                    <option value="1">0 Year</option>
                    <option value="2">1 Year</option>
                    <option value="3">2 Year</option>
                    <option value="4">3 Year</option>
                    <option value="5">4 Year</option>
                    <option value="6">5 Year</option>
                    <option value="7">6 Year</option>
                    <option value="8">7 Year</option>
                    <option value="9">8 Year</option>
                    <option value="10">9 Year</option>
                    <option value="11">10 Year</option>
                    <option value="12">11 Year</option>
                    <option value="12">11 Year</option>
                    <option value="13">12 Year</option>
                    <option value="14">13 Year</option>
                    <option value="15">14 Year</option>
                    <option value="16">15 Year</option>
                    <option value="17">16 Year</option>
                    <option value="18">17 Year</option>
                    <option value="19">18 Year</option>
                    <option value="20">19 Year</option>
                  </select>   <select name="selectTimeToMaturityMonthFrom" id="selectTimeToMaturityMonthFrom" style="width: 70px">
                    <option  value="0">--Month--</option>
                    <option value="1">0 Month</option>
                    <option value="2">1 Month</option>
                    <option value="3">2 Month</option>
                    <option value="4">3 Month</option>
                    <option value="5">4 Month</option>
                    <option value="6">5 Month</option>
                    <option value="7">6 Month</option>
                    <option value="8">7 Month</option>
                    <option value="9">8 Month</option>
                    <option value="10">9 Month</option>
                    <option value="11">10 Month</option>
                    <option value="12">11 Month</option>
                  </select>&nbsp;to &nbsp; <select name="selectTimeToMaturityYearTo" id="selectTimeToMaturityYearTo" 
                          style="width: 50px">
                    <option  value="0">--Year--</option>
                    <option value="1">0 Year</option>
                    <option value="2">1 Year</option>
                    <option value="3">2 Year</option>
                    <option value="4">3 Year</option>
                    <option value="5">4 Year</option>
                    <option value="6">5 Year</option>
                    <option value="7">6 Year</option>
                    <option value="8">7 Year</option>
                    <option value="9">8 Year</option>
                    <option value="10">9 Year</option>
                    <option value="11">10 Year</option>
                    <option value="12">11 Year</option>
                    <option value="12">11 Year</option>
                    <option value="13">12 Year</option>
                    <option value="14">13 Year</option>
                    <option value="15">14 Year</option>
                    <option value="16">15 Year</option>
                    <option value="17">16 Year</option>
                    <option value="18">17 Year</option>
                    <option value="19">18 Year</option>
                    <option value="20">19 Year</option>
                  </select>  <select name="selectTimeToMaturityMonthTo" id="selectTimeToMaturityMonthTo" style="width: 70px">
                    <option  value="0">--Month--</option>
                    <option value="1">0 Month</option>
                    <option value="2">1 Month</option>
                    <option value="3">2 Month</option>
                    <option value="4">3 Month</option>
                    <option value="5">4 Month</option>
                    <option value="6">5 Month</option>
                    <option value="7">6 Month</option>
                    <option value="8">7 Month</option>
                    <option value="9">8 Month</option>
                    <option value="10">9 Month</option>
                    <option value="11">10 Month</option>
                    <option value="12">11 Month</option>
                  </select> </td>
                </tr>
				 <tr>
                  <td style="text-align: right">After Matured : </td>
                  <td>&nbsp;</td>
                  <td>from&nbsp;&nbsp; <select name="selectAfterMaturedYearFrom" id="selectAfterMaturedYearFrom" 
                          style="width: 50px" >
                    <option  value="0">--Year--</option>
                    <option value="1">0 Year</option>
                    <option value="2">1 Year</option>
                    <option value="3">2 Year</option>
                    <option value="4">3 Year</option>
                    <option value="5">4 Year</option>
                    <option value="6">5 Year</option>
                    <option value="7">6 Year</option>
                    <option value="8">7 Year</option>
                    <option value="9">8 Year</option>
                    <option value="10">9 Year</option>
                    <option value="11">10 Year</option>
                    <option value="12">11 Year</option>
                    <option value="12">11 Year</option>
                    <option value="13">12 Year</option>
                    <option value="14">13 Year</option>
                    <option value="15">14 Year</option>
                    <option value="16">15 Year</option>
                    <option value="17">16 Year</option>
                    <option value="18">17 Year</option>
                    <option value="19">18 Year</option>
                    <option value="20">19 Year</option>
                  </select>   <select name="selectAfterMaturedMonthFrom" id="selectAfterMaturedMonthFrom" style="width: 70px">
                    <option  value="0">--Month--</option>
                    <option value="1">0 Month</option>
                    <option value="2">1 Month</option>
                    <option value="3">2 Month</option>
                    <option value="4">3 Month</option>
                    <option value="5">4 Month</option>
                    <option value="6">5 Month</option>
                    <option value="7">6 Month</option>
                    <option value="8">7 Month</option>
                    <option value="9">8 Month</option>
                    <option value="10">9 Month</option>
                    <option value="11">10 Month</option>
                    <option value="12">11 Month</option>
                  </select>&nbsp;to &nbsp; 
                      <select name="selectAfterMaturedYearTo" id="selectAfterMaturedYearTo" 
                          style="width: 50px">
                    <option value="0">--Year--</option>
                    <option value="1">0 Year</option>
                    <option value="2">1 Year</option>
                    <option value="3">2 Year</option>
                    <option value="4">3 Year</option>
                    <option value="5">4 Year</option>
                    <option value="6">5 Year</option>
                    <option value="7">6 Year</option>
                    <option value="8">7 Year</option>
                    <option value="9">8 Year</option>
                    <option value="10">9 Year</option>
                    <option value="11">10 Year</option>
                    <option value="12">11 Year</option>
                    <option value="12">11 Year</option>
                    <option value="13">12 Year</option>
                    <option value="14">13 Year</option>
                    <option value="15">14 Year</option>
                    <option value="16">15 Year</option>
                    <option value="17">16 Year</option>
                    <option value="18">17 Year</option>
                    <option value="19">18 Year</option>
                    <option value="20">19 Year</option>
                  </select>  <select name="selectAfterMaturedMonthTo" id="selectAfterMaturedMonthTo" style="width: 70px">
                    <option  value="0">--Month--</option>
                    <option value="1">0 Month</option>
                    <option value="2">1 Month</option>
                    <option value="3">2 Month</option>
                    <option value="4">3 Month</option>
                    <option value="5">4 Month</option>
                    <option value="6">5 Month</option>
                    <option value="7">6 Month</option>
                    <option value="8">7 Month</option>
                    <option value="9">8 Month</option>
                    <option value="10">9 Month</option>
                    <option value="11">10 Month</option>
                    <option value="12">11 Month</option>
                  </select> </td>
                </tr>

				 <tr>
                  <td style="text-align: right">Transaction Date : </td>
                  <td>&nbsp;</td>
                  <td>from&nbsp;&nbsp; <input name="dtTranDateFrom" type="text" id="dtTranDateFrom" 
                          style="text-align:center " value="" size="10" >
                      
                      &nbsp;to &nbsp;
                      
                      <input name="dtTranDateTo" type="text" id="dtTranDateTo" style="text-align:center "
                           value="" size="10" ></td>
                </tr>

				 <tr>
                  <td><div align="right">Status   : </div></td>
                  <td>&nbsp;</td>
                  <td><select name="selectStatus" id="selectStatus">
                    <option  value="0">--Select data--</option>
                    <option value="Purchase">Purchase</option>
                    <option value="Sale">Sale</option>
                    <option value="Guarantee">Guarantee</option>
                  </select>
                      &nbsp; </td>
                </tr>
                 <tr>
                  <td ><div align="right">Cost Yield/Interest Rate :&nbsp; </div></td>
                  <td >&nbsp;</td>
                  <td style="width: 236px;  ">
                 <input type="radio" name="chkMaxMin" id="chkAll" value="all"/> All  
                 <input type="radio" name="chkMaxMin" id="chkMax" value="max"/> Max &nbsp;&nbsp;&nbsp;
                 <input type="radio"  name="chkMaxMin" id="chkMin" value="min"/> Min
                     </td>
                  <td  >&nbsp;</td>
                 </tr>

                <tr>
                  <td><div align="right">Related / Non Related :&nbsp; </div></td>
                  <td>&nbsp;</td>
                  <td><select name="selectRelated" id="selectRelated">
                      <option  value="0">--Select data--</option>
                      <option value="1">เกี่ยวข้อง</option>
                      <option value="2">ไม่เกี่ยวข้อง</option>
                      <option value="3">3</option>
                    </select></td>
                </tr>

                <tr>
                  <td><div align="right"></div></td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
              </table>
		      <table width="95%"  border="0" align="center">
                <tr>
                  <td><div align="center">
  <input type="submit" name="btnSearch" class="button" value=" Search ">
  &nbsp;&nbsp;&nbsp;
  <input type="reset" name="Submit4" class="button" value=" Reset ">&nbsp;&nbsp;&nbsp;<input type="button" name="btnExport"  id="btnExport" class="button" value=" Export ">
                  </div></td>
                </tr>
              </table>
}

              @{
    var grid = new WebGrid(Model,canSort: false, canPage: true, rowsPerPage: 20, 
    selectionFieldName: "selectedRow",ajaxUpdateContainerId: "gridContent");
       grid.Pager(WebGridPagerModes.NextPrevious);
        } 




<div id="gridContent">
    @grid.GetHtml( 
            tableStyle : "Wbgrid",
            alternatingRowStyle : "Wbalt",
            headerStyle : "Wbhead",
            
            columns: grid.Columns(
            
            grid.Column("no","No"),
            grid.Column("Company"," Company"),
            grid.Column("FinancialInstrument", "Financial Instrument", style: "description"),
            grid.Column("AssetClass", "Asset Class"),
            grid.Column("Symbol", "Symbol"),
            grid.Column("TransactionType", "Trans. Type"),
            grid.Column("TransactionDate", "Trans. Date"),
            grid.Column("Issuer", "Issuer"),
            grid.Column("KeepAt", "Keep At"),
            grid.Column("TimeToMaturity", "TTM(Year)"),
            grid.Column("CostYieldInterestRate", "Cost / Yield / Interest Rate"),
            grid.Column("RelatedNonRelated", "Related / Non Related"),
          
            
            
          grid.Column(header: "Details",
            format: @<text><img src="@Url.Content("~/Content/Images//b_edit.gif")"
             style="cursor: pointer" onClick="gogo('@item._page','@item._folder','@item.HeaderId')"                                                                     
             alt="View Detail" title="View Detail"/></text>) 
     )) 
</div>

	
		  <br></td>
        </tr>
    </table>
    </p>

